package com.example.war;

import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import net.rbgrn.android.glwallpaperservice.*;

//Original code provided by Robert Green
//http://www.rbgrn.net/content/354-glsurfaceview-adapted-3d-live-wallpapers
public class WarWallpaperService extends GLWallpaperService {
 public WarWallpaperService() {
     super();
 }

 public Engine onCreateEngine() {
     MyEngine engine = new MyEngine();
     return engine;
 }

 class MyEngine extends GLEngine {
     MyRenderer renderer;
     public MyEngine() {
         super();
         // handle prefs, other initialization
         renderer = new MyRenderer(WarWallpaperService.this);
         setRenderer(renderer);
         setRenderMode(RENDERMODE_CONTINUOUSLY);
     }

     @Override
    public void onTouchEvent(MotionEvent event) {
         super.onTouchEvent(event);
         renderer.onTouchEvent(event);
    }

    @Override
    public void onSurfaceChanged(SurfaceHolder holder, int format, int width,
            int height) {
        // TODO Auto-generated method stub
        super.onSurfaceChanged(holder, format, width, height);
        Log.d("xiaobo","Service onSurfaceChanged");
    }

    @Override
    public void onSurfaceCreated(SurfaceHolder holder) {
        // TODO Auto-generated method stub
        super.onSurfaceCreated(holder);
        Log.d("xiaobo","Service onSurfaceCreated");
    }

    @Override
    public void onSurfaceDestroyed(SurfaceHolder holder) {
        super.onSurfaceDestroyed(holder);
        Log.d("xiaobo","Service onSurfaceDestroyed");
    }

    @Override
    public void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        Log.d("xiaobo","onPause");
    }

    @Override
    public void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        Log.d("xiaobo","onResume");
    }

    public void onDestroy() {
    	Log.d("zzzz","-------- onDestroy----------");
         super.onDestroy();
         if (renderer != null) {
             renderer.release();
         }
         renderer = null;
     }
 }
}
